﻿namespace JCodeGen
{
    public class ObjectDataSourceGenerator : CodeGenBase
    {
        private string ID;
        private string TypeName;
        private string DataObjectTypeName;
        private string SelectMethod;
        private string InsertMethod;
        private string UpdateMethod;
        private string DeleteMethod;
        private string SelectCountMethod;

        public ObjectDataSourceGenerator(
            string ID,
            string TypeName,
            string DataObjectTypeName) : this(
                ID,
                TypeName,
                DataObjectTypeName,
                "Select",
                "Insert",
                "Update",
                "Delete",
                "SelectCount"){}

        internal ObjectDataSourceGenerator(
            string ID,
            string TypeName,
            string DataObjectTypeName,

            string SelectMethod,
            string InsertMethod,
            string UpdateMethod,
            string DeleteMethod,
            string SelectCountMethod)
        {
            this.ID = ID;
            this.TypeName = TypeName;
            this.DataObjectTypeName = DataObjectTypeName;
            this.SelectMethod = SelectMethod;
            this.InsertMethod = InsertMethod;
            this.UpdateMethod = UpdateMethod;
            this.DeleteMethod = DeleteMethod;
            this.SelectCountMethod = SelectCountMethod;
        }

        protected override void SetReplacement()
        {
            AddReplacement("ID", ID);
            AddReplacement("TypeName", TypeName);
            AddReplacement("DataObjectTypeName", DataObjectTypeName);

            AddReplacement("SelectMethod", SelectMethod);
            AddReplacement("InsertMethod", InsertMethod);
            AddReplacement("UpdateMethod", UpdateMethod);
            AddReplacement("DeleteMethod", DeleteMethod);
            AddReplacement("SelectCountMethod", SelectCountMethod);
        }

    }
}
